package com.atguigu.gmall;

import com.atguigu.gmall.model.product.SkuInfo;

import java.util.concurrent.CompletableFuture;

/**
 * @author: 李旭
 * @create: 2021-07-12 11:31
 **/
public class CompletableFutureDemo {

    //异步编排
    public static void main(String[] args) throws Exception{
        //1:创建新的线程

        // 传递基本类型  返回值基本类型
       /* CompletableFuture<String> hahahha = CompletableFuture.completedFuture("hahahha");
        System.out.println(hahahha.get());*/

    /*    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                5,
                10,
                2,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10)

        );*///pool-1-thread-1
        CompletableFuture<Void> voidCompletableFuture = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
        });//ForkJoinPool.commonPool-worker-1

        CompletableFuture<SkuInfo> integerCompletableFuture = CompletableFuture.supplyAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            return new SkuInfo();
        });


       // CompletableFuture.allOf(voidCompletableFuture).join();
    }
}
